* Run on Stata 13 for Mac (OS 9)
* June 3, 2016

*************************************************
* TABLE A.1 - SUMMARY STATISTICS
*************************************************

* Table A.1 has three panels, as many as levels of analysis: country, industry, firm. 
* For each level, I run descriptive statistics


*** Set Path
* cd "..."

*******************
* UPPER PANEL
*******************

use "firm_industry_country.dta", clear

* Winsorize based on Labor
sort digit2
bysort digit2: egen max=pctile(labor), p(99)
bysort digit2: egen min=pctile(labor), p(1) 
bysort digit2: gen winso_labor = labor if (labor>min & labor<max)
drop max min
drop if winso_labor == . 

* Normalized Tax Compliance
gen scaled_taxcomp = taxcomp/100

gen government = 1 if public_share>50 & public_share<= 100
replace government = 0 if public_share>=0 & public_share<=50
gen ln_firm_age = ln(age)
gen ln_firm_labor = ln(labor)
gen ln_tot_pop = ln(tot_pop)
gen ln_firm_exports = ln(1+exportshare)

sum scaled_taxcomp ln_firm_age ln_firm_labor  ln_firm_exports government iso

*******************
* LOWER PANEL
*******************

use "industry_country.dta", clear

*  Tariffs by Others
bysort digit2 : gen case = _n
bysort digit2: egen total = max(case)
order tariff, after(total)
bysort digit2: egen total_tariff = total(tariff)
gen total_tariff_without_case = total_tariff - tariff
gen total_without_case = total - 1 
gen mean_tariff_foreign_industry = total_tariff_without_case/total_without_case

sum  wtaxcomp uwtaxcomp lnavgexp avgcompetitors lnavgage lntotlabor gov_owner_share  obsolete tariff mean_tariff_foreign_industry


*******************
* LOWER PANEL
*******************

* Normalized Tax Revenue and VAT
gen scaled_taxy = taxy/100
gen scaled_vaty = vaty/100

sum taxstaff scaled_taxy scaled_vaty free_media ln_tot_pop region sector mining
